package com.enterprise.dao.impl;

import com.enterprise.dao.BaseDao;
import com.enterprise.dao.LawyerDao;
import com.enterprise.entity.Lawyer;
import com.enterprise.entity.page.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description TODO
 * @Author 以梦为馬 <Douglas1314@126.com>
 * @Version V1.0.0
 * @Date 2020-08-16 22:28
 **/
@Repository("lawyerDao")
public class LawyerDaoImpl implements LawyerDao {

    /**
     * mybatis 提供的dao基类接口
     */
    @Autowired
    private BaseDao baseDao;


    public void setBaseDao(BaseDao baseDao) {
        this.baseDao = baseDao;
    }


    /**
     * 新增接口
     * 参数说明：第一个参数"lawyer.insert" 对应sql的xml文件中的新增sql方法名
     *          第二个参数：新增对象
     * @param lawyer
     * @return
     */
    @Override
    public int insert(Lawyer lawyer) {
        return baseDao.insert("lawyer.insert",lawyer);
    }

    @Override
    public int delete(Lawyer lawyer) {
        return baseDao.delete("lawyer.delete",lawyer);
    }

    @Override
    public int update(Lawyer lawyer) {
        return baseDao.update("lawyer.update",lawyer);
    }

    @Override
    public Lawyer selectOne(Lawyer lawyer) {
        return (Lawyer) baseDao.selectOne("lawyer.selectOne",lawyer);
    }

    @Override
    public PageModel selectPageList(Lawyer lawyer) {
        return baseDao.selectPageList("lawyer.selectPageList","lawyer.selectPageCount",lawyer);
    }

    @Override
    public List<Lawyer> selectList(Lawyer lawyer) {
        return baseDao.selectList("lawyer.selectList",lawyer);
    }

    @Override
    public int deleteById(int id) {
        return baseDao.delete("lawyer.deleteById",id);
    }

    @Override
    public Lawyer selectById(int id) {
        return (Lawyer) baseDao.selectOne("lawyer.selectById",id);
    }
}
